package com.iscas.tech.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.iscas.tech.entity.AtModulevalue;
import com.iscas.tech.mapper.AtModulevalueMapper;
import com.iscas.tech.param.AtModulevaluePageParam;
import com.iscas.tech.service.AtModulevalueService;
import com.iscas.tech.vo.AtModulevalueQueryVo;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.pagination.PageUtil;
import io.geekidea.springbootplus.framework.pagination.Paging;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 项目基础信息模块值表 服务实现类
 *
 * @author yangyi
 * @since 2020-10-26
 */
@Slf4j
@Service
public class AtModulevalueServiceImpl extends BaseServiceImpl<AtModulevalueMapper, AtModulevalue> implements AtModulevalueService {

    @Autowired
    private AtModulevalueMapper atModulevalueMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean saveAtModulevalue(AtModulevalue atModulevalue) throws Exception {
        return super.save(atModulevalue);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean updateAtModulevalue(AtModulevalue atModulevalue) throws Exception {
        return super.updateById(atModulevalue);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteAtModulevalue(Long id) throws Exception {
        return super.removeById(id);
    }

    @Override
    public Paging<AtModulevalueQueryVo> getAtModulevaluePageList(AtModulevaluePageParam atModulevaluePageParam) throws Exception {
        Page page = PageUtil.getPage(atModulevaluePageParam, OrderItem.desc(getLambdaColumn(AtModulevalue::getCreatetime)));
        IPage<AtModulevalueQueryVo> iPage = atModulevalueMapper.getAtModulevaluePageList(page, atModulevaluePageParam);
        return new Paging(iPage);
    }

    @Override
    public List<AtModulevalueQueryVo> getAllInMd(Long mdId) throws Exception {
        return atModulevalueMapper.getAllInMd(mdId);
    }

}
